/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.MIDlet;
import javax.wireless.messaging.MessageConnection;

/**
 * @author BinhLT SUNNET
 */
public class SunnetMIDlet extends MIDlet {

    public static SunnetFlash sunnetFlash;
    public Display display;
    MessageConnection serverConn;
    public SunnetCanvas sunnetCanvas;
    public SunnetGameCanvas gameCanvas;
    public static boolean continues = false;

    public void startApp() {
        display = Display.getDisplay(this);
        sunnetFlash = new SunnetFlash(this);
        display.setCurrent(sunnetFlash);
    }

    public void init() {
        sunnetCanvas = new SunnetCanvas(this);
    }
    public void showGame() {
        if (gameCanvas == null) {
            gameCanvas = new SunnetGameCanvas(this);
            sunnetCanvas.setGameCanvas(gameCanvas);
        }
        if (continues) {
            gameCanvas.continueGame();
        } else {
            gameCanvas.newGame();
        }
        gameCanvas.start();
        display.setCurrent(gameCanvas);
    }

    public void showMenu() {
        display.setCurrent(sunnetCanvas);
    }

    public void pauseApp() {
        Runtime.getRuntime().gc();
    }
    public void destroyApp(boolean unconditional) {
        display = null;
        if (sunnetFlash != null) {

            sunnetFlash.isDisplay = false;
            sunnetFlash = null;

        }
        Runtime.getRuntime().gc();
        this.notifyDestroyed();
    }
}
